<template>
  <div id="info" :class="{ 'isPc': fun.isPc() }" v-if="show_page">
    <c-title :hide="false" :text="apply_for_type == 'lawYerManagement' ? '律师申请' : apply_for_type == 'lawOffice' ? '律所申请' : '基本信息'"></c-title>
    <div class="apply_img">
      <img :src="paransInfo.l_top_thumb_image" alt="" />
    </div>
    <template v-if="!is_apply">
      <van-field
        required
        v-model="info.name"
        :label="apply_for_type == 'lawYerManagement' || apply_for_type == 'lawyerDetail' ? '姓名' : '律所名称'"
        input-align="right"
        :placeholder="apply_for_type == 'lawYerManagement' ? '请填写姓名' : '请填写律所名称'"
      />

      <div class="logo">
        <van-field name="uploader" :label="apply_for_type == 'lawYerManagement' || apply_for_type == 'lawyerDetail' ? '头像' : 'logo'">
          <template #input>
            <van-uploader v-model="upload_photo.logo" max-count="1" :after-read="onRead_logo" />
          </template>
        </van-field>
      </div>
      <div class="gender" v-if="apply_for_type == 'lawYerManagement' || apply_for_type == 'lawyerDetail'">
        <van-cell :border="false" center is-link>
          <span slot="title">性别</span>
          <input slot="default" type="text" @click="showGender = true" v-model="info.gender" readonly placeholder="请选择性别" />
        </van-cell>
      </div>
      <van-field
        required
        v-model="info.mobile"
        type="number"
        :label="apply_for_type == 'lawYerManagement' ? '手机号' : '联系电话'"
        input-align="right"
        :placeholder="apply_for_type == 'lawYerManagement' ? '请输入手机号' : '请输入联系电话'"
      />
      <div class="desc" v-if="apply_for_type == 'lawOffice' || apply_for_type == 'officeDetail'">
        <van-field autosize required v-model="info.desc" label="简介" type="textarea" />
      </div>
      <div class="gender" v-if="apply_for_type == 'lawYerManagement' || apply_for_type == 'lawyerDetail'">
        <van-cell :border="false" center is-link>
          <span slot="title">律所所属</span>
          <input slot="default" type="text" @click.stop="showOffice = true" v-model="info.office" readonly placeholder="请选择律所所属" />
        </van-cell>
      </div>
      <div class="office" v-if="apply_for_type == 'lawYerManagement' || apply_for_type == 'lawyerDetail'">
        <van-cell :border="false" center is-link>
          <span slot="title">擅长领域</span>
          <div class="office-choose">
            <span v-for="item in info.currentGood" class="current" :key="item.id">
              <img @click="closeGood(item)" class="close-good" src="../../../assets/images/close-orange.png" />
              {{ item.title }}</span
            >
          </div>
          <template #right-icon>
            <van-icon name="arrow" class="search-icon" @click="confirmGood('open')" />
          </template>
        </van-cell>
      </div>
      <template v-if="apply_for_type == 'lawYerManagement' || apply_for_type == 'lawyerDetail'">
        <van-field required v-model="info.job_year" label="执业年限" input-align="right" placeholder="请填写执业年限" />
        <van-field required v-model="info.job_name" label="职称" input-align="right" placeholder="请填写职称" />
        <van-field required v-model="info.job_no" label="执业证号" input-align="right" placeholder="请填写执业证号" />
      </template>
      <div class="certification">
        <div class="certification-header">{{ apply_for_type == "lawYerManagement" || apply_for_type == "lawyerDetail" ? "执业证照片" : "资质" }}</div>
        <van-uploader v-model="upload_photo.Practice" max-count="1" :after-read="onRead_practice" />
      </div>
      <template v-if="apply_for_type == 'lawYerManagement' || apply_for_type == 'lawyerDetail'">
        <van-field  label="身份证人像面"></van-field>
        <div class="card">
          <van-uploader v-model="upload_photo.identity_card_front" :after-read="onRead_front" :max-count="1" :deletable="true">
            <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/debt/card.png" />
          </van-uploader>
        </div>
        <van-field  label="身份证国徽面"></van-field>
        <div class="card">
          <van-uploader v-model="upload_photo.identity_card_backend" :after-read="onRead_backend" :max-count="1" :deletable="true">
            <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/debt%2FcardF.png" />
          </van-uploader>
        </div>
        <van-cell-group :border="false" class="set-address">
          <van-cell :border="false" center is-link>
            <span slot="title">执业起始时间</span>
            <input slot="default" type="text" @click.stop="jobShow = true" v-model="info.job_time" readonly placeholder="请选择执业起始时间" />
          </van-cell>
        </van-cell-group>
      </template>
      <div class="desc" v-if="apply_for_type == 'lawYerManagement' || apply_for_type == 'lawyerDetail'">
        <van-field required v-model="info.desc" label="简介" autosize type="textarea" />
      </div>
      <van-cell-group :border="false" class="set-address">
        <van-cell :border="false" center is-link>
          <span slot="title">{{ apply_for_type == "lawYerManagement" || apply_for_type == "lawyerDetail" ? "服务区域" : "律所所在地址" }}</span>
          <input
            slot="default"
            type="text"
            @click.stop="addressShow = true"
            v-model="info.addressName"
            readonly
            :placeholder="apply_for_type == 'lawYerManagement' || 'lawyerDetail' ? '请选择服务区域' : '请选择律所所在地址'"
          />
        </van-cell>
        <template v-if="strShow">
          <van-cell :border="false" center is-link >
            <span slot="title">街道</span>
            <input slot="default" type="text" @click.stop="streetChoose" v-model="info.street" readonly placeholder="请选择街道" />
          </van-cell>
        </template>

        <van-cell :border="false" center v-if="apply_for_type == 'lawYerManagement' || apply_for_type == 'lawyerDetail'">
          <span slot="title">地理位置</span>
          <div class="location">
            <input slot="default" type="text" v-model="info.locationTitle" readonly />
            <i class="iconfont icon-dingwei" style="color: #f86e6e; padding-right: 0.25rem;"></i>
            <span :style="info.locationTitle?'width:12%':'width:30%'" @click="toGeolocation">{{ info.locationTitle ? "切换" : "自动定位" }}</span>
          </div>
        </van-cell>
      </van-cell-group>
      <template v-if="apply_for_type == 'lawOffice' || apply_for_type == 'officeDetail'">
        <van-field required v-model="info.detailed_address" label="详细地址" placeholder="请输入详细地址" input-align="right" />
      </template>
        <div class="enterprise"  v-if="apply_for_type == 'lawOffice'&&columnsOffice.length>1">
        <van-cell :border="false" center is-link>
          <span slot="title">关联企业</span>
          <input slot="default" type="text" @click.stop="openEnterprise" v-model="enterprise_name" readonly placeholder="请选择关联企业" />
        </van-cell>
      </div>
      <template v-if="apply_for_type == 'officeDetail'">
        <div class="office-status">
          <div>状态</div>
          <div>
            <van-radio-group v-model="status" direction="horizontal">
              <van-radio :name="1">经营</van-radio>
              <van-radio :name="0">休息</van-radio>
            </van-radio-group>
          </div>
        </div>
      </template>
      <van-checkbox v-if="paransInfo.l_status == 1" class="confirm" icon-size="35rpx" v-model="agremment">
        <span>阅读并同意申请</span><span class="agremment" @click.stop="agreementShow = true">《申请协议》</span></van-checkbox
      >
      <div class="btn">
        <van-button color="#daa032" @click="submit">提交</van-button>
      </div>
    </template>
    <template v-if="is_apply">
      <div class="wait">你已申请过律师，等待审核~</div>
      <div class="btn">
        <van-button color="#daa032" @click="back">返回</van-button>
      </div>
    </template>
    <!-- 省市区地址选择器 -->
    <yd-cityselect style="height: 80%;" v-model="addressShow" :callback="addressCallback" :items="district"></yd-cityselect>
    <!-- 所属律所 -->
    <van-popup v-model="showOffice" position="bottom" :style="{ height: '40%' }">
      <div class="good-wrapper">
        <div class="good-header">
          <span class="good-cancel" @click="showOffice = false">取消</span>
          <span class="good-title">所属律所</span>
          <span class="good-confirm" @click="confirmOffice">确认</span>
        </div>
        <div class="lawyer-office" ref="lawyerOffice">
         <van-search v-model="search_lawyer_firm" placeholder=" 输入律师事务所名称" v-if="apply_for_type=='lawYerManagement'" />
          <van-radio-group v-model="radio">
            <van-cell-group>
              <van-cell v-for="item in columnsOffice" :title="item.name" :key="item.id" clickable @click="radio = item.id">
                <template #right-icon>
                  <van-radio label-position="left" :name="item.id" />
                </template>
              </van-cell>
            </van-cell-group>
          </van-radio-group>
        </div>
      </div>
    </van-popup>
      <!-- 关联企业 -->
    <van-popup v-model="showEnterprise" position="bottom" :style="{ height: '40%' }">
      <div class="good-wrapper">
        <div class="good-header">
          <span class="good-cancel" @click="closeEnterprise">取消</span>
          <span class="good-title">关联企业</span>
          <span class="good-confirm" @click="confirmEnterprise">确认</span>
        </div>
        <div class="lawyer-office" ref="enterprise">
          <van-radio-group v-model="radio_enterprise">
            <van-cell-group>
              <van-cell v-for="item in columnsEnterprise" :title="item.name" :key="item.id" clickable @click.stop="radio_enterprise = item.id">
                <template #right-icon>
                  <van-radio label-position="left" :name="item.id" />
                </template>
              </van-cell>
            </van-cell-group>
          </van-radio-group>
        </div>
      </div>
    </van-popup>
    <!-- 擅长领域 -->
    <van-popup v-model="showGood" position="bottom" :style="{ height: '40%' }">
      <div class="good-wrapper">
        <div class="good-header">
          <span class="good-cancel" @click="confirmGood('cancel')">取消</span>
          <span class="good-title">擅长领域</span>
          <span class="good-confirm" @click="confirmGood('confirm')">确认</span>
        </div>
        <div class="good-content">
          <span v-for="(item, i) in columnsGood" :key="item.id" @click="chooseGood(i)" :class="{ current: item.status }">{{ item.title }}</span>
        </div>
      </div>
    </van-popup>
    <!-- 执业时间 -->
    <van-popup v-model="jobShow" position="bottom">
      <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" :min-date="minDate" :max-date="maxDate" @cancel="jobShow = false" @confirm="confirmJobTime" />
    </van-popup>
    <!-- 街道选择器  -->
    <van-popup v-model="streetShow" round position="bottom" :style="{ height: '80%' }">
      <div class="m-dialog1">
        <van-nav-bar title="选择街道" class="pcStyle_ydT">
          <template #left>
            <span>
              <van-icon name="arrow-left" size="18" @click.native="streetShow = false" color="#333" />
            </span>
          </template>
        </van-nav-bar>
        <van-cell :border="false" center is-link v-for="(item, i) in districtVal" :key="i" @click.native="streetConfirm(item)" title-style="text-align:left">
          <span slot="title">{{ item.areaname }}</span>
        </van-cell>
      </div>
    </van-popup>
    <!-- 性别选择器-->
    <van-overlay :show="showGender" @click="showGender = false" z-index="200">
      <div class="wrapper" @click.stop>
        <div class="gender-wrapper">
          <div class="gender-header">
            <h4>请选择性别</h4>
            <van-icon name="cross" @click="showGender = false" />
          </div>
          <div class="gender-box">
            <div>
              <img style="width: 4.2rem; height: 4.2rem;" :src="genderImg.man" alt="" @click="toggleGender('man')" />
              <div>男</div>
            </div>
            <div class="or">或</div>
            <div>
              <img style="width: 4.2rem; height: 4.2rem;" :src="genderImg.women" alt="" @click="toggleGender('women')" />
              <div>女</div>
            </div>
          </div>
        </div>
      </div>
    </van-overlay>
    <!-- 协议 -->
    <div v-if="agreementShow" class="agreementShow">
          <div class="wrapper">
        <div class="block">
          <div class="block-title">申请协议</div>
          <div v-html="paransInfo.l_content"></div>
          <div class="close">
            <van-icon name="cross" size="25px"  @click="agreementShow = false" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import apply_for_controller from "./apply_for_controller";
export default apply_for_controller;
</script>

<style lang="scss" scoped>
.agreementShow {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1001;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
}

.gender-box {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.or {
  color: #d2d2d2;
  margin-top: -1rem;
}

.confirm {
  margin-top: 1rem;
  margin-left: 1rem;
}

.agremment {
  padding-left: 10px;
  color: #fb5944;
}

.close {
  position: absolute;
  right: 7px;
  top: 7px;
}

.gender-wrapper {
  position: relative;
  text-align: center;
  width: 20.7rem;
  height: 13.5rem;
  border: 0.2rem;
  background-color: #fff;
}

.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  position: relative;
  overflow-y: scroll;
  width: 301px;
  height: 376px;
  background-color: #fff;
  text-align: center;
  padding-left: 16px;
  padding-right: 16px;
  border-radius: 1rem;
}

.block-title {
  margin-top: 10px;
  margin-bottom: 36px;
  font-size: 14px;
}

.location {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

#info {
  position: relative;
  height: 100%;
  background: #fff;
  padding-bottom: 10rem;
}

input {
  border: none;
}

.logo {
  ::v-deep .van-cell {
    justify-content: space-between;
    align-items: center;
  }

  ::v-deep .van-field__value {
    flex: 0;
  }

  ::v-deep .van-uploader__upload {
    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
  }
}

.btn {
  position: absolute;
  width: 100%;
  bottom: 0;
  z-index: 1000;
  background-color: #fff;
  box-shadow: 0 -2px 7px 0 rgba(213, 213, 213, 0.59);
  padding: 0.5714rem 1.7857rem;

  ::v-deep .van-button--normal {
    width: 100%;
    border-radius: 0.3571rem;
  }
}

.desc {
  ::v-deep .van-cell {
    display: flex;
    flex-direction: column;
  }

  ::v-deep .van-field__value {
    border: solid 1px #cfcfcf;
    border-radius: 0.3rem;
    margin-top: 0.2rem;
    padding: 0.5rem;
  }
}

.enterprise {
  .van-cell {
    position: relative;
    padding: 10px 12px;

    .van-cell__title {
      flex: none;
      color: #555;
      text-align: left;
      padding-left: 0.2rem;
    }

    .van-cell__value {
      padding-left: 0.2rem;

      input {
        color: #555;
        width: 100%;
        text-align: right;
      }
    }
  }

  ::v-deep .van-cell:active {
    background-color: #fff !important;
  }
}

.set-address,
.office,
.gender {
  .van-cell {
    position: relative;
    padding: 10px 12px;

    .van-cell__title {
      flex: none;
      color: #555;
      text-align: left;
      padding-left: 0.2rem;
    }

    .van-cell__value {
      padding-left: 0.2rem;

      input {
        color: #555;
        width: 100%;
        text-align: right;
      }
    }
  }

  ::v-deep .van-cell:active {
    background-color: #fff !important;
  }
}

.gender-header {
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;

  h4 {
    flex: 1;
  }

  .van-icon {
    margin-left: auto;
  }
}

.certification {
  text-align: left;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  padding-left: 1.1rem;

  &::before {
    position: absolute;
    left: 8px;
    color: #ee0a24;
    font-size: 13px;
    content: "*";
  }
}

.certification-header {
  margin-bottom: 0.8rem;
}

.logo,
.gender,
.office,
.set-address {
  .van-cell {
    &::before {
      position: absolute;
      left: 8px;
      color: #ee0a24;
      font-size: 13px;
      content: "*";
    }
  }
}

.good-wrapper {
  display: flex;
  flex-direction: column;
}

.good-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem 0;
}

.good-cancel {
  color: #8e8e8e;
}

.good-title {
  font-size: 1.2rem;
  color: #202020;
}

.good-cancel {
  color: #8e8e8e;
}

.good-confirm {
  color: #daa032;
}

.good-content {
  padding-left: 1rem;
  padding-right: 1rem;
  display: flex;
  // justify-content: space-evenly;
  flex-wrap: wrap;
}

.good-content span {
  // width: 4.6rem;
  height: 1.8rem;
  line-height: 1.8rem;
  color: #7c7c7c;
  text-align: center;
  border: solid 0.1rem #d6d6d6;
  border-radius: 0.2rem;
  padding: 0 0.6rem;
  margin: 0.8rem 0.5rem 0.1rem;
}

.current {
  color: #f5b435 !important;
  border: solid 0.1rem #f5b435 !important;
}

.office-choose {
  display: flex;
  flex-wrap: wrap;
  padding-left: 3rem;
  padding-top: 0.2rem;
}

.office-choose span {
  position: relative;
  margin: 0.3rem;
  font-size: 10px;
  padding: 0 0.2rem;
}

.wait {
  margin: 2rem auto 0;
}

.close-good {
  width: 1rem;
  position: absolute;
  right: -0.5rem;
  top: -0.5rem;
}

.card {
  position: relative;
  text-align: left;
  padding: 10px 16px;
  background-color: #fff;

  img {
    width: 13.5rem;
  }

  .photo-upload {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 4.14rem;
    height: 4.14rem;
    border-radius: 100px;
    opacity: 0.8;
    text-align: center;
    line-height: 5.14rem;
    background-color: #108ee9;
  }
}

.van-cell::after {
  border-bottom: unset !important;
}

.blod-text {
  color: #333;
  font-weight: bold;
}

.addressDiv {
  width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 18px;
}

.lawyer-office {
  height: 18rem;
  overflow-y: auto;
  position: relative;

  ::v-deep .van-cell__title {
    text-align: left;
  }
}

.apply_img {
  width: 100%;

  img {
    width: 100%;
  }
}

.office-status {
  display: flex;
  padding: 1rem;
  justify-content: space-between;
}

.isPc {
  max-width: 375px;
}
</style>
